home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / aurora2c.zip / DELBLANK.AML < prev    next >
Text File  |  1995-04-07  |  2KB  |  59 lines

  1.  
  2. // ───────────────────────────────────────────────────────────────────
  3. // The Aurora Editor v2.0
  4. // Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
  5. //
  6. // Delete blank lines in a file or block
  7. //
  8. // This macro deletes blank lines in the current edit window. The
  9. // operation is confined to a marked block if one exists.
  10. //
  11. // (Note: this macro will run faster if undo is disabled)
  12. // ───────────────────────────────────────────────────────────────────
  13.  
  14.   include bootpath "define.aml"
  15.  
  16.   var count
  17.  
  18.   // test for edit windows
  19.   if not wintype? "edit" then
  20.     msgbox "Edit windows only!"
  21.     return
  22.   end
  23.  
  24.   // test if a marked block exists in the current file
  25.   block_count = mark? and getmarkbuf == getcurrbuf
  26.  
  27.   // display message
  28.   say "Deleting blank lines" + (if? block_count " in block") + "..."
  29.  
  30.   // set search options
  31.   options = "x*" + (if? block_count 'b')
  32.  
  33.   // save cursor position and goto first line
  34.   pushcursor
  35.   gotopos 1 (if? block_count (getmarktop) 1)
  36.  
  37.   // mark the beginning of an undoable group of operations
  38.   undobegin
  39.  
  40.   // search for blank lines using regular expressions
  41.   while find "^ *$" options do
  42.     delline
  43.     count = count + 1
  44.   end
  45.  
  46.   // mark the end of an undoable group of operations
  47.   undoend
  48.  
  49.   // restore cursor
  50.   popcursor
  51.  
  52.   // clear the title bar
  53.   display
  54.  
  55.   // display the word count
  56.   shortbox  (if? count (thousands count) "No") + " lines deleted" +
  57.             (if? block_count " in the block")
  58.  
  59.